package com.as3.timbot.command
{
	import com.as3.timbot.command.Command;
	import com.as3.timbot.iso.Actor;
	import com.as3.timbot.command.CommandEvent;
	
	import flash.events.EventDispatcher;
	import flash.events.Event;

	public class AbstractCommand implements Command
	{
		private var __dispatcher:EventDispatcher;
		private var __event:CommandEvent;
		
		public function AbstractCommand()
		{
			__dispatcher = new EventDispatcher();
		}
		public function execute():void
		{
			
			
		}
		public function addEventListener(type:String,callback:Function):void
		{
			__dispatcher.addEventListener(type,callback);
		}
		protected function begin():void
		{
			__event = new CommandEvent(CommandEvent.START);
			fireEvent();
		}
		protected function end():void
		{
			__event = new CommandEvent(CommandEvent.COMPLETE);
			fireEvent();
		}
		protected function progress(value:Number):void
		{
			__event=new CommandEvent(CommandEvent.PROGRESS);
			__event.setProgress(value);
			fireEvent();
		}
		protected function fireEvent():void
		{
			__event.setCommand(this);
			__dispatcher.dispatchEvent(__event);
		}
		protected function fireEventType(value:Event):void
		{
			__dispatcher.dispatchEvent(value);
		}
		
	}
}